// recommendList.js
const regeneratorRuntime = require('../../lib/runtime');
const wx = require('../../lib/wx');
const Api = require('../../utils/api.js');
const wxapp = require('../../lib/wxapp');

// 获取应用实例
const app = getApp();
Page({
  data: {
    productList: [
      {
        imgUrl: '',
        url: '../productDetail/productDetail',
        title: '',
        price: '',
        discount: '',
        shop: '',
      },
      
    ],
  },

  goToMenu: wxapp.handler(function* goToMenu(next, e){
    const url = e.currentTarget.dataset.url;
    wx.reLaunch({
      url,
    });

    yield next;
  }),

  goToDetail: wxapp.handler(function* goToDetail(next, e){
    const url = e.currentTarget.dataset.url;
    wx.navigateTo({
      url: url,
    });

    yield next;
  }),

  onShow: wxapp.handler(function* onShow(next) {

    yield next;
  }),

  onLoad: wxapp.handler(function* onLoad(next) {

    yield next;

    var that = this;
    var getRecommendList = Api.getRecommendList();
    // 商品列表
    wx.request({
      url: getRecommendList,
      header: {
        'content-type': 'application/json'
      },
      method: 'GET',
      data: {
        
      },
      complete: function (res) {
        that.setData({ productList: res.data.data });
      }
    });
  }),

});
